package T54Exception;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class Student {
	private String name;
	private int score;
	@Override
	public String toString() {
		return "Student [name=" + name + ", score=" + score + "]";
	}
	public String getName() {
		return name;
	}
	public void setName (String name) throws IllegalNameException{
		if(Character.isDigit(name.charAt(0))){
			this.name=name;
			throw new IllegalNameException("the first char of name must not be digit, name="+name);
		}
		this.name = name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public int addScore(int score)throws IllegalScoreException{
		int newscore=this.score+score;
		if(newscore<0||newscore>100){
			this.score=newscore;
			throw new IllegalScoreException("score out of range, score="+newscore);
		}
		this.score=newscore;
		return newscore;
		
	}


}
